﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Quartz.Net.Model;
using System.Data.OracleClient;
using System.Data;

namespace Quartz.Net.DAL
{
   public class Task_Quartz_JoinDAL
    {

       public IEnumerable<Task_Quartz_JobtriggerRunModel> GetJobRun()
       {
           List<Task_Quartz_JobtriggerRunModel> Task_Quartz_JobtriggerRunModel = new List<Task_Quartz_JobtriggerRunModel>();

           string strSql = "select j.*,r.nguid runguid,r.lasttime,r.nexttime from task_quartz_jobtrigger j left join task_quartz_run r on j.nguid = r.jobguid where j.valid = '1'";
          
           DataTable dt = DalBase.ExecuteDataTable(strSql, null);
           foreach (DataRow dr in dt.Rows)
           {
               Task_Quartz_JobtriggerRunModel.Add(ToModel(dr));
           }


           return Task_Quartz_JobtriggerRunModel;

       }

       private Task_Quartz_JobtriggerRunModel ToModel(DataRow dr)
       {
           Task_Quartz_JobtriggerRunModel model = new Task_Quartz_JobtriggerRunModel();
           model.NGUID = Convert.ToString(dr["NGUID"]);
           model.JOBNAME = Convert.ToString(dr["JOBNAME"]);
           model.JOBGROUPNAME = Convert.ToString(dr["JOBGROUPNAME"]);
           model.TRIGGERNAME = Convert.ToString(dr["TRIGGERNAME"]);
           model.TRIGGERGROUPNAME = Convert.ToString(dr["TRIGGERGROUPNAME"]);
           model.JOBPATH = Convert.ToString(dr["JOBPATH"]);
           model.JOBCRON = Convert.ToString(dr["JOBCRON"]);
           model.JOBJJ = Convert.ToString(dr["JOBJJ"]);
           model.XH = Convert.ToString(dr["XH"]);
           model.RUNSTATUS = Convert.ToString(dr["RUNSTATUS"]);
           model.ISCHANGE = Convert.ToString(dr["ISCHANGE"]);
           model.VALID = Convert.ToString(dr["VALID"]);
           model.JOBSNAME = Convert.ToString(dr["JOBSNAME"]);
           model.RUNGUID = Convert.ToString(dr["RUNGUID"]);
           model.LASTTIME = Convert.ToString(dr["LASTTIME"]);
           model.NEXTTIME = Convert.ToString(dr["NEXTTIME"]);
           return model;
       }
    }
}
